{% load mptt_tags %}

{% comment %}
{% full_tree_for_model structure.StructureNode as nodes %}
<ul class="root nav nav-list">
    {% recursetree nodes %}
        {% if node.level %}
            {% if node.menu_visible %}
                <li class="{% if node == current_node %}active{% endif %}">
                    <a href="{{ node.path }}" >{{ node.get_menu }}</a>
                    {% if not node.is_leaf_node %}
                        <ul class="children">
                            {{ children }}
                        </ul>
                    {% endif %}
                </li>
            {% endif %}
        {% else %}
            {% if node.menu_visible %}
            <li class="{% if node == current_node %}active{% endif %}" >
                <a href="{{ node.path }}">{{ node.get_menu }}</a>
            </li>
            {% endif %}
            {{ children }}
        {% endif %}
    {% endrecursetree %}
</ul>
{% endcomment %}

{% full_tree_for_model structure.StructureNode as nodes %}
    <ul id="main-nav" class="nav pull-right">

        {% recursetree nodes %}
            {% if node.level == 1 %}
                {% if node.menu_visible %}
                <li class="{% if node.menu_visible_children.count %}dropdown{% endif %} {% if node.menu_ico_only %}nav-icon{% endif %} {% if node == current_root_node or node == current_top_node %}active{% endif %}" >
                    {% if node.menu_visible_children.count %}
                        <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
                            {% if node.menu_ico %}<i class="{{ node.menu_ico }}"></i>{% endif %}
                            <span>{{ node.get_menu }}</span>
                            <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu">
                            {{ children }}
                        </ul>
                    {% else %}

                        <a href="{{ node.path }}">
                            {% if node.menu_ico %}<i class="{{ node.menu_ico }}"></i>{% endif %}
                            <span>{{ node.get_menu }}</span>
                        </a>
                    {% endif %}
                    </a>
                </li>
                {% endif %}
            {% endif %}
            {% if node.level == 2 %}
                {% if node.menu_visible %}
                <li {% if node.menu_visible_children.count %}class="dropdown-submenu"{% endif %} >
                    {% if node.menu_visible_children.count %}
                        <a tabindex="-1" href="#">
                            {{ node.get_menu }}
                        </a>
                        <ul class="dropdown-menu">
                            {{ children }}
                        </ul>
                    {% else %}
                        <a href="{{ node.path }}">{{ node.get_menu }}</a>
                    {% endif %}
                    </a>
                </li>
                {% endif %}
            {% endif %}
            {% if node.level == 0 %}
                {{ children }}
            {% endif %}


            {% if node.level == 3 %}
                {% if node.menu_visible %}
                <li><a href="{{ node.path }}">{{ node.get_menu }}</a></li>
                {% endif %}
            {% endif %}
        {% endrecursetree %}
    </ul>
